<template>
  <div class="page-content center-center">
    <div>
      <div class="title-info text-left">
        基本信息（必填）
      </div>
      <div class="center-center">
        <el-form class="myForm" :model="modelForm" ref="modelFormInfo" label-width="100px" style="width: 800px;">
          <el-form-item prop="no" label=" " :rules="[
                        { required: true, message: '请输入请输入商品编码', trigger: 'blur' },
                            { min: 5, max: 5, message: '请输入5位编码', trigger: 'blur' }
                        ]">
            <el-input placeholder="请输入商品编码" v-model="modelForm.no" :maxlength="10" size="medium">
              <template slot="prepend">
                <el-tooltip placement="top" content="（编码为五位数字,不可重复）">
                  <el-button tabIndex="-1">商品编码</el-button>
                </el-tooltip>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item prop="name" label=" " :rules="[ { required: true, message: '请输入商品名称', trigger: 'blur' }]">
            <el-input placeholder="请输入商品名称" @blur="setPy()" v-model="modelForm.name" :maxlength="32" size="medium">
              <template slot="prepend">
                <el-tooltip placement="top" content="（此项为必填项，不能填写已有的商品！）">
                  <el-button tabIndex="-1">商品名称</el-button>
                </el-tooltip>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item prop="spell" label=" " :rules="[{ required: true, message: '请输入快捷码', trigger: 'blur' }]">
            <el-input placeholder="请输入快捷码" v-model="modelForm.spell" :maxlength="32" size="medium">
              <template slot="prepend">
                <el-tooltip placement="top" content="（此项根据商品名称自动生成,也可自行修改！）">
                  <el-button tabIndex="-1">快捷码</el-button>
                </el-tooltip>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label=" " prop="goodsSpec" :rules="[]" v-if="storeType=='HB' || storeType=='LS' || storeType=='SX'">
            <el-input placeholder="请输入规格型号" v-model="stockForm.goodsSpec" size="medium" :maxlength="20">
              <template slot="prepend">
                <el-tooltip placement="top" content="请填写规格型号,例如：12瓶/箱">
                  <el-button tabIndex="-1">规格型号</el-button>
                </el-tooltip>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item prop="category" label=" " :rules="[
                            { required: true, message: '选择所需商品类别', trigger: 'blur',type: 'number'},
                            { type: 'number', message: '请选择正确类别'}
                        ]">
            <div class="el-input el-input-group el-input-group--prepend">
              <el-tooltip style="border-right:0px solid #c0c0c0" placement="top" content="（选择所需商品类别，不能不选！）">
                <div class="el-input-group__prepend">商品分类</div>
              </el-tooltip>
              <el-select v-model="modelForm.category" filterable placeholder="请选择商品分类" size="medium" class="w-100p">
                <el-option
                  v-for="item in categoryList"
                  :key="item.id"
                  :label="item.name"
                  :disabled="(item.state && item.state.key!='NORMAL')"
                  :value="item.id">
                </el-option>
              </el-select>
            </div>
          </el-form-item>
          <el-form-item prop="unit" label=" "
                        :rules="[{ required: true, message: '请选择商品单位', trigger: 'change'}]">
            <div class="el-input el-input-group el-input-group--prepend">
              <div class="el-input-group__prepend" tabIndex="-1">商品单位</div>
             <!-- <el-select v-model="modelForm.unit" filterable :filter-method="selectUnit" @blur="unitBlur" class="w-100p" placeholder="请选择商品单位" size="medium" >
                <el-option
                  v-for="item in dishesUnitList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.name">
                </el-option>
              </el-select>-->
              <el-autocomplete
                class="inline-input w-100p"
                v-model="modelForm.unit"
                :fetch-suggestions="querySearch"
                placeholder="请选择商品单位"
                custom-item="my-item-zh"
                @select="handleSelect"
                @change="findUnit"
              ></el-autocomplete>
            </div>
          </el-form-item>

          <div v-if="storeType=='SX' || storeType=='LS'">
            <el-form-item prop="brandId" label=" " :rules="[]">
              <div class="el-input el-input-group el-input-group--prepend">
                <el-tooltip style="border-right:0px solid #c0c0c0" placement="top" content="（选择所需商品品牌，不能不选！）">
                  <div class="el-input-group__prepend">商品品牌</div>
                </el-tooltip>
                <el-select v-model="modelForm.brandId" filterable placeholder="请选择商品品牌" size="medium" class="w-100p">
                  <el-option
                    v-for="item in brands"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id">
                  </el-option>
                </el-select>
              </div>
            </el-form-item>
          </div>


          <el-form-item label=" " :rules="[]" v-if="storeType=='ZC' || storeType=='KC'">
            <div style="border: 1px solid #bfcbd9;padding-left:10px;text-align: left">
              <el-checkbox v-model="moreSpecifications" v-if="!modelForm.weigh">多规格</el-checkbox>
              <el-checkbox v-model="moreSpecifications" v-if="modelForm.weigh" disabled>多规格</el-checkbox>
            </div>
            <div class="orderTable" v-if="moreSpecifications">
              <el-table
                :data="specificationsTableData"
                border
                style="width: 100%">
                <el-table-column
                  type="index"
                  width="50">
                </el-table-column>
                <el-table-column
                  width="80">
                  <template slot-scope="scope">
                    <span class="el-icon-plus" style="cursor: pointer;font-size: 10px;padding-right: 5px"
                          @click="addSpecifColumn(scope.$index)"></span>
                    <span class="el-icon-minus" style="cursor: pointer;font-size: 10px;padding-left: 5px"
                          @click="minusSpecifColumn(scope.$index)"></span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="specificationsId"
                  label="规格">
                  <template slot-scope="scope">
                    <div style="position: relative">
                      <el-select v-model="scope.row.specificationsId" @change="changeGuige(scope.$index)">
                        <el-option
                          v-for="item in dishesSpecificationList"
                          :key="item.id"
                          :label="item.name"
                          :disabled="item.state.key!='NORMAL'"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="money"
                  label="单价">
                  <template slot-scope="scope">
                    <el-input v-model.number="scope.row.money" @blur="moneyJiaoyan(scope.row,'money')"
                              placeholder="0.00" size="medium" @focus="printNum"></el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="vipMoney"
                  label="会员价">
                  <template slot-scope="scope">
                    <el-input v-model.number="scope.row.vipMoney" @blur="vipMoneyJiaoyan(scope.row,'vipMoney')"
                              placeholder="0.00" size="medium" @focus="printNum"> </el-input>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="isDefault"
                  label="默认（是/否）">
                  <template slot-scope="scope">
                    <el-switch
                      v-model="scope.row.isDefault"
                      on-color="#13ce66"
                      on-text="是"
                      @change="defaultChange(scope.$index)"
                      off-text="否"
                      off-color="#ff4949">
                    </el-switch>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-form-item>
          <el-form-item label=" " v-if="!moreSpecifications" prop="price"
                        :rules="[{ required: true, message: '请输入商品价格', trigger: 'blur',type: 'number'},rules.numPot2]">
            <el-input placeholder="请输入商品价格" v-model.number="modelForm.price" size="medium" @focus="printNum" @blur="changePrice">
              <template slot="prepend">
                <el-tooltip placement="top" content="（此项为必填项，请填写原料单价，如：1.5，2...）">
                  <el-button tabIndex="-1">商品价格</el-button>
                </el-tooltip>
              </template>
              <template slot="append">
                <div style="cursor: pointer;">元</div>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label=" " v-if="moreSpecifications" prop="price" :rules="[rules.numPot2]">
            <el-input placeholder="请输入商品价格" v-model.number="modelForm.price" disabled size="medium" @focus="printNum">
              <template slot="prepend">
                <el-tooltip placement="top" content="（此项为必填项，请填写会员价，如：1.5，2...）">
                  <el-button tabIndex="-1">商品价格</el-button>
                </el-tooltip>
              </template>
              <template slot="append">
                <div style="cursor: pointer;">元</div>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label=" " v-if="moreSpecifications" prop="vipPrice" :rules="[rules.numPot2]">
            <el-input placeholder="请输入会员价格" v-model.number="modelForm.vipPrice" disabled size="medium">
              <template slot="prepend">
                <el-tooltip placement="top" content="（此项为必填项，请填写会员价，如：1.5，2...）">
                  <el-button tabIndex="-1">会员价格</el-button>
                </el-tooltip>
              </template>
              <template slot="append">
                <div style="cursor: pointer;">元</div>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item label=" " v-if="!moreSpecifications" prop="vipPrice"
                        :rules="[{ required: true, message: '请输入会员价格', trigger: 'blur',type: 'number' },rules.numPot2]">
            <el-input placeholder="请输入会员价格" v-model.number="modelForm.vipPrice" size="medium">
              <template slot="prepend">
                <el-tooltip placement="top" content="（此项为必填项，请填写会员价，如：1.5，2...）">
                  <el-button tabIndex="-1">会员价格</el-button>
                </el-tooltip>
              </template>
              <template slot="append">
                <div style="cursor: pointer;">元</div>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item prop="futureCost" :rules="[rules.numPot2]">
            <el-input placeholder="请输入预估成本" v-model="modelForm.futureCost" size="medium">
              <template slot="prepend">
                <el-tooltip placement="top" content="(请填写参考成本价，系统最终会优先根据本商品成本卡的配置匹配成本)">
                  <el-button tabIndex="-1">
                    <span v-if="storeType=='HB' || storeType=='LS' || storeType=='SX'">采购成本价</span>
                    <span v-else>预估成本</span>
                    </el-button>
                </el-tooltip>
              </template>
              <template slot="append">元</template>
            </el-input>
          </el-form-item>
          <!--商品条码 可以添加多个 start-->
          <!--<div v-if="storeType=='LS' || storeType=='SX'">-->
            <el-form-item label=" " prop=""   v-for="(item,index) in codeList" :key="index" style="padding-right: 55px">
              <el-input placeholder="请输入条码" v-model="item.code" :maxlength="13">
                <template slot="prepend">
                  <el-button tabIndex="-1">条码{{index+1}}</el-button>
                </template>
                <template slot="append" v-if="index!=0"><i class="icon icon-jjian-" @click="delCode(index)"></i></template>
              </el-input>

              <div style="position: absolute;right:-41px; top: 2px; " @click="addCode()"><i class="icon icon-jia"
                                                                                    style="font-size: 23px;color:#20a0ff"></i></div>

            </el-form-item>
          <!--</div>-->
          <!--商品条码 可以添加多个 end-->


        </el-form>
      </div>
      <!--烘焙行业 start-->
      <div v-if="storeType=='HB' || storeType=='LS' || storeType=='SX'">
        <div class="title-info">
          <el-row>
            <el-col :span="10" class="text-left">
              库存信息&nbsp;&nbsp;
            </el-col>
            <el-col :span="14" class="center-center text-left">
              <div class="text-right" style="width:100%;color:#016cdf;cursor: pointer;">
                  <span @click="stockShowInfo=stockShowInfo?false:true">
                      <span v-if="stockShowInfo"><i class="icon icon-shang" style="font-size:15px"></i>收起显示</span>

                      <span v-if="!stockShowInfo"><i class="icon icon-weibiaoti35" style="font-size:14px;"></i>展开显示</span>
                  </span>
              </div>
            </el-col>
          </el-row>
        </div>

        <div class="center-center text-left" v-show="stockShowInfo">
          <el-form :model="stockForm" class="stockForm" ref="stockForm" label-width="100px" style="width: 800px;">


            <el-form-item label=" " prop="minStock" :rules="[rules.numPot2]">
              <el-input placeholder="请输入最低库存" v-model.number="stockForm.minStock" @blur="isNum(modelForm,'minStock')" size="medium" :maxlength="10">
                <template slot="prepend">
                  <el-tooltip placement="top" content="（不足最低库存时，库存报表以红色标识）">
                    <el-button tabIndex="-1">最低库存</el-button>
                  </el-tooltip>
                </template>
              </el-input>
            </el-form-item>
            <el-form-item label=" " prop="maxStock" :rules="[rules.numPot2]">
              <el-input placeholder="请输入最高库存" v-model.number="stockForm.maxStock" @blur="isNum(modelForm,'maxStock')" size="medium" :maxlength="10">
                <template slot="prepend">
                  <el-tooltip placement="top" content="（高于最高库存时，库存报表以绿色标识）">
                    <el-button tabIndex="-1">最高库存</el-button>
                  </el-tooltip>
                </template>
              </el-input>
            </el-form-item>
          <!--  <el-form-item label=" " prop="orderPriceBom" :rules="[rules.numPot2]">
              <el-input placeholder="请输入成本卡标准价" @blur="isNumber(stockForm,'orderPriceBom')" v-model="stockForm.orderPriceBom" size="medium" :maxlength="10">
                <template slot="prepend">
                  <el-tooltip placement="top" content="请填写成本卡标准价">
                    <el-button tabIndex="-1">成本卡标准价</el-button>
                  </el-tooltip>
                </template>
              </el-input>
            </el-form-item>-->
            <el-form-item label=" " prop="storeMode" :rules="[]">
              <div class="el-input el-input-group el-input-group--prepend el-input--medium">
                <div class="el-input-group__prepend" tabindex="-1">储存方式</div>
                <el-select v-model="stockForm.storeMode" filterable placeholder="（根据所需选择储存方式，非必选！）"
                           class="w-100p"  size="medium">
                  <el-option v-for="item in storeModes" :key="item.key" :label="item.text" :value="item.key">
                  </el-option>
                </el-select>
              </div>
            </el-form-item>
            <el-form-item label=" " prop="orderType" :rules="[{ required: true, message: '选择所需订货类型', trigger: 'blur',  }]">
              <div class="el-input el-input-group el-input-group--prepend el-input--medium">
                <div class="el-input-group__prepend" tabindex="-1">订货类型</div>
                <el-select v-model.number="stockForm.orderType" filterable size="medium"
                           class="w-100p"
                           placeholder="请选择订货类型">
                  <el-option v-for="item in orderTypes" :key="item.key" :label="item.text" :value="item.key">
                  </el-option>
                </el-select>
              </div>
            </el-form-item>
            <el-form-item label=" " prop="stocktakeType" :rules="[{ required: true, message: '请选择盘点类型', trigger: 'blur' }]">
              <div class="el-input el-input-group el-input-group--prepend el-input--medium">
                <div class="el-input-group__prepend" tabindex="-1">盘点类型</div>

                <el-select v-model="stockForm.stocktakeType" filterable placeholder="请选择盘点类型" class="w-100p" size="medium">
                  <el-option v-for="item in stocktakeTypes" :key="item.key" :label="item.text"
                             :value="item.key">
                  </el-option>
                </el-select>
              </div>
            </el-form-item>

            <!--      <!--动态编辑[采购规格]--start============================================-->
            <!--动态编辑[采购规格]-->
            <div class="cggg-con" v-if="purchase && purchase.length>0"
                 v-for="(pur,index) in purchase">
              <div class="text-right" style="position: relative;">
                <el-button type="text" @click="delPurchase(index)" tabIndex="-1">删除规格</el-button>
              </div>
              <el-form :model="pur" :ref="'pur'+index" style="height:230px;" class="demo-ruleForm">
                <el-form-item prop="purchaseSpec" :rules="[{ required: true, message: '采购规格不能为空且不能重复', trigger: 'blur' }]">
                  <el-input placeholder="请输入采购规格" v-model="pur.purchaseSpec" size="medium">
                    <template slot="prepend">
                      <el-tooltip placement="top" content="请填写采购规格, 例如 12瓶/箱">
                        <el-button tabIndex="-1">采购规格{{index+1}}</el-button>
                      </el-tooltip>
                    </template>
                  </el-input>
                </el-form-item>
                <el-form-item prop="purchaseUnit" :rules="[{ required: true, message: '请选择采购单位', trigger: 'change' }]"
                              class="el-form-item__content_margin"
                              style="margin-left: 0;">
                  <div class="el-input el-input-group el-input-group--prepend el-input--medium">
                    <div class="el-input-group__prepend" tabIndex="-1">采购单位</div><!--remote  allow-create default-first-option  :remote-method="selectPurUnit" -->
                    <!-- <el-select v-model="pur.purchaseUnit" filterable :filter-method="selectPurchaseUnit" @blur="unitBlur"   placeholder="选择所需采购单位，必选！" class="w-100p" @focus="getIndex(index)" >
                       <el-option v-for="(item,itemIndex) in dishesUnitList" :key="itemIndex" :label="item.name" :value="item.name"
                                  :disabled="item.disabled">
                       </el-option>
                     </el-select>-->
                    <el-autocomplete
                      class="inline-input w-100p"
                      v-model="pur.purchaseUnit"
                      :fetch-suggestions="querySearch"
                      placeholder="请选择采购单位"
                      custom-item="my-item-zh"
                      @select="handleSelect2"
                      @click.native="selectConsumeUnit(index)"
                    ></el-autocomplete>
                  </div>
                </el-form-item>
                <el-form-item prop="purchaseCount" :rules="[rules.numPot2]">
                  <el-input placeholder="请输入采购单位与库存单位的换算值" v-model="pur.purchaseCount" @blur="isPositive(pur,'purchaseCount')" size="medium">
                    <template slot="prepend">
                      <el-tooltip placement="top" content="此字段表示一个采购单位对应多少个库存单位，比如:1箱(采购单位)=10瓶(库存单位),此处应填写10">
                        <el-button tabIndex="-1">采购->库存单位换算值</el-button>
                      </el-tooltip>
                    </template>
                  </el-input>
                </el-form-item>

                <el-form-item prop="purchasePrice" :rules="[rules.numPot2]">
                  <el-input placeholder="请输入此采购规格的采购单价" v-model.number="pur.purchasePrice" size="medium" :maxlength="10"
                            @blur="isPositive(pur,'purchasePrice')">
                    <template slot="prepend">
                      <el-tooltip placement="top" content="（填写此采购规格的采购单价，例如：1，1.5...）">
                        <el-button tabIndex="-1">此规格价格</el-button>
                      </el-tooltip>
                    </template>
                  </el-input>
                </el-form-item>
              </el-form>
            </div>

            <div class="text-right" style="margin:10px;margin-right: 100px;">
              <el-button type="primary" @click="addPurchase()">添加采购规格</el-button>
            </div>
            <!-- <!--动态编辑[采购规格]--=end===========================================--->
          </el-form>
        </div>

      </div>
      <!--烘焙行业 end-->

      <div class="title-info">
        <el-row>
          <el-col :span="10" class="text-left">
            其他信息&nbsp;&nbsp;
          </el-col>
          <el-col :span="14" class="center-center text-left">
            <div class="text-right" style="width:100%;color:#016cdf;cursor: pointer;">
                            <span @click="showInfo=showInfo?false:true">
                                <span v-if="showInfo"><i class="icon icon-shang" style="font-size:15px"></i>收起显示</span>

                                <span v-if="!showInfo"><i class="icon icon-weibiaoti35" style="font-size:14px;"></i>展开显示</span>
                            </span>
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="center-center text-left" v-show="showInfo">
        <el-form :model="modelForm" class="myForm" ref="modelFormImg" label-width="100px" style="width: 800px;">
          <el-row style="margin-left:30px" v-if="storeType=='ZC' || storeType=='KC' || storeType=='HB'">
            <el-col :span="5">
              <div class="grid-content bg-purple">
                <el-upload
                  class="avatar-uploader"
                  action="/management/image/upload"
                  :show-file-list="false"
                  :with-credentials="true"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <img v-if="modelForm.img" style="width:150px;height:150px;" :src="modelForm.img" class="avatar">
                  <div v-if="!modelForm.img"
                       style="width:150px;height:150px;border:1px solid #c0c0c0;background: #f8f8f8;line-height:150px;color:#dcdcdc">
                    <i class="el-icon-plus avatar-uploader-icon"
                       style="border: 1px dashed #dcdcdc;padding: 17px;"></i>
                  </div>
                  <div>&nbsp;</div>
                </el-upload>
              </div>
            </el-col>
            <el-col :span="17" :offset="2">
              <div style="background: #f8f8f8;width:82%;height: 100px;display: inline-block;padding: 25px 0;">
                <el-row class="center-center">
                  <el-col :span="6" class="text-center">
                    <span v-if="storeType=='HB'">甜</span>
                    <span v-if="storeType!='HB'">辣</span>
                    度
                  </el-col>
                  <el-col :span="18">
                    <el-rate
                      v-model="modelForm.hot"
                      :colors="['#99A9BF', '#F7BA2A', '#FF9900']">
                    </el-rate>
                  </el-col>
                </el-row>
                <br>
                <br>
                <el-row class="center-center">
                  <el-col :span="6" class="text-center">
                    推荐度
                  </el-col>
                  <el-col :span="18">
                    <el-rate
                      v-model="modelForm.recommend"
                      :colors="['#99A9BF', '#F7BA2A', '#FF9900']">
                    </el-rate>
                  </el-col>
                </el-row>
              </div>
            </el-col>
          </el-row>
          <el-form-item label=" " prop="weigh" :rules="[]">
            <div style="border: 1px solid #bfcbd9;padding-left:10px">
              <el-checkbox v-model="modelForm.weigh"
                           @change="modelForm.weigh ? moreSpecifications=false : moreSpecifications=moreSpecifications">
                称重商品
              </el-checkbox> &nbsp;&nbsp;&nbsp;<span style="font-size: 12px;color: red">称重商品单位要与电子秤设置的单位保持一致</span>
            </div>
          </el-form-item>
          <el-form-item label=" " :rules="[]" v-if="storeType=='ZC' || storeType=='KC' || storeType=='HB'">
            <div style="border: 1px solid #bfcbd9;padding-left:10px">
              <el-checkbox v-model="morePractice">多做法</el-checkbox>&nbsp;&nbsp;&nbsp;<span
              style="font-size: 12px;color: red">*商品配置做法后必选，请为商品配置不加价的做法作为默认做法。</span>
            </div>
            <!--{{tableData}}-->
            <div style="padding-left:10px" v-if="morePractice">
              做法分类: <span v-for="item in makeCategoryList" style="margin:0 10px"
                          @click="getCurrentMakeCategory(item.id,item.typeId,item.name)" v-if="item.count>0"><el-button type="text"
                                                                                          style="color:black"
                                                                                          :class="{'deco':selectMake==item.id}" >{{item.name}}({{item.calcCount}}/{{item.count}})</el-button></span>
            </div>
            <div class="orderTable" v-if="morePractice">
              <el-table
                :data="tableData"
                border
                style="width: 100%">
                <el-table-column
                  type="index"
                  width="50">
                </el-table-column>
                <el-table-column
                  width="80">
                  <template slot-scope="scope">
                    <span class="el-icon-plus" style="cursor: pointer;font-size: 10px;padding-right: 5px"
                          @click="addColumn(scope.$index)"></span>
                    <span class="el-icon-minus" style="cursor: pointer;font-size: 10px;padding-left: 5px"
                          @click="minusColumn(scope.$index)"></span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="practiceId"
                  label="做法">
                  <template slot-scope="scope">
                    <div style="position: relative">
                      <el-select v-model.number="scope.row.practiceId"
                                 @change="changeZuoFa(scope.$index)">
                        <el-option
                          v-for="item in dishesPracticeList"
                          :key="item.id"
                          :label="item.name"
                          :disabled="item.state.key!='NORMAL'"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="premiumRate"
                  label="加价比例">
                  <template slot-scope="scope">
                    <el-select v-model="scope.row.premiumRate" @change="premiumRateChange(scope.row)">
                      <el-option
                        v-for="item in priceupTypes"
                        :key="item.key"
                        :label="item.text"
                        :value="item.key">
                      </el-option>
                    </el-select>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="money"
                  label="比例/金额">
                  <template slot-scope="scope">
                    <el-input v-if="scope.row.premiumRate!='DONOTADD'" v-model="scope.row.money"
                              @blur="isDouble(scope.row,'money')" placeholder="0.00" @focus="printNum">
                    </el-input>
                    <label style="position: absolute;z-index: 5;right: 10px;top: 0px;"
                           v-if="scope.row.premiumRate=='PROPROTIONADD'">%</label>
                    <label v-if="scope.row.premiumRate=='DONOTADD'">0.00</label>

                  </template>
                </el-table-column>
                <el-table-column
                  prop="isDefault"
                  label="默认（是/否）">
                  <template slot-scope="scope">
                    <el-switch
                      v-model="scope.row.def"
                      on-color="#13ce66"
                      on-text="是"
                      @change="defaultMakeChange(scope.$index)"
                      off-text="否"
                      off-color="#ff4949">
                    </el-switch>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-form-item>

          <!--<el-form-item prop="printCategory" :rules="[]">-->
            <!--<div class="el-input el-input-group el-input-group&#45;&#45;prepend">-->
              <!--<el-tooltip style="border-right:0px solid #c0c0c0" placement="top" content="（选择菜品打印大类，此项非必选项！）">-->
                <!--<div class="el-input-group__prepend">打印大类</div>-->
              <!--</el-tooltip>-->
              <!--<el-select v-model="modelForm.printCategory" filterable placeholder="请选择菜品打印大类" size="medium" class="w-100p">-->
              <!--<el-option-->
                <!--v-for="item in printerCategoryUnitList"-->
                <!--:key="item.id"-->
                <!--:label="item.name"-->
                <!--:disabled="item.state.key!='NORMAL'"-->
                <!--:value="item.id">-->
              <!--</el-option>-->
              <!--</el-select>-->
            <!--</div>-->
          <!--</el-form-item>-->
          <el-form-item label=" " prop="commission" :rules="[]">
            <div style="border: 1px solid #bfcbd9;padding-left:10px">
              <el-checkbox v-model="modelForm.season">时价商品</el-checkbox>&nbsp;&nbsp;&nbsp;<span
              style="font-size: 12px;color: red"></span>
            </div>
          </el-form-item>
          <el-form-item label=" " prop="commission" :rules="[]" v-if="storeType=='ZC' || storeType=='KC' || storeType=='HB'">
            <div style="border: 1px solid #bfcbd9;padding-left:10px">
              <el-checkbox v-model="isFeed">是否加料</el-checkbox>&nbsp;&nbsp;&nbsp;

              <span v-if="isFeed"
                                v-for="item in feedCategoryList"
                                style="margin:0 10px;"
                                @click="getCurrentFeedCategory(item.id,item.calcCount)">

              <el-button type="text" style="color:black"
                         :class="{'deco':selectFeed==item.id}" v-if="item.count>0">
                {{item.name}}({{item.calcCount}}/{{item.count}})
              </el-button>
               <!-- <div v-if="isFeed">
                  <el-checkbox :indeterminate="isIndeterminate" v-model="item.checkAll" @change="handleCheckAllChange">全选
                  </el-checkbox>
                </div>-->
              </span>
              <div v-if="isFeed" style="padding-left:30px;">

                <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选
                </el-checkbox>
                <!--<div style="margin:6px 0;"></div>-->
                <el-checkbox-group v-model="checkFeed" @change="handleCheckedCitiesChange">
                  <el-checkbox v-for="item in feedList" :label="item.id" :key="item.id"   @change="getValue">{{item.name}}</el-checkbox>
                </el-checkbox-group>
              </div>
            </div>
          </el-form-item>
          <!--</el-form-item>-->
          <el-form-item label=" " prop="commission" :rules="[]">
            <div style="border: 1px solid #bfcbd9;padding-left:10px">
              <el-checkbox v-model="modelForm.commission">商品提成</el-checkbox>&nbsp;&nbsp;&nbsp;<span
              style="font-size: 12px;color: red">（此项为必选项，不选默认为停用！）</span>
            </div>
          </el-form-item>

          <el-row>
            <el-col :span="16">
              <el-form-item label=" " v-if="modelForm.commission" prop="commissionType"
                            :rules="[{ required: true, message: '请选择提成类型', trigger: 'blur'}]">
                <div class="el-input el-input-group el-input-group--prepend">
                  <el-tooltip style="border-right:0px solid #c0c0c0" placement="top" content="（选择商品打印大类，此项非必选项！）">
                    <div class="el-input-group__prepend">提成类型</div>
                  </el-tooltip>
                  <el-select v-model="modelForm.commissionType" style="width: 57%" placeholder="请选择" size="medium">
                    <el-option
                      v-for="item in commissionTypes"
                      :key="item.key"
                      :label="item.text"
                      :value="item.key">
                    </el-option>
                  </el-select>
                </div>

              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label=" " v-if="modelForm.commission" prop="commissionValue"
                            :rules="[{ required: true, message: '请输入提成值', trigger: 'blur',type:'number' },rules.numPot2]">
                <el-input placeholder="请输入提成值" v-if="modelForm.commissionType=='PROPORTION'" size="medium"
                          @blur="isNum(modelForm,'commissionValue')" v-model.number="modelForm.commissionValue">
                  <template slot="append">
                    <el-tooltip placement="top" content="请填写提成值">
                      <el-button tabIndex="-1">%</el-button>
                    </el-tooltip>
                  </template>
                </el-input>
                <el-input placeholder="请输入提成值" v-if="modelForm.commissionType=='FIXEDAMOUNT'" size="medium"
                          @blur="isNum(modelForm,'commissionValue')" v-model.number="modelForm.commissionValue">
                  <template slot="append">
                    <el-tooltip placement="top" content="请填写提成值">
                      <el-button tabIndex="-1">元</el-button>
                    </el-tooltip>
                  </template>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-form-item prop="nameEn" :rules="[]">
            <el-input placeholder="请输入英文名称" v-model="modelForm.nameEn" :maxlength="32" size="medium">
              <template slot="prepend">
                <el-tooltip placement="top" content="请填写英文名称">
                  <el-button tabIndex="-1">英文名称</el-button>
                </el-tooltip>
              </template>
            </el-input>
          </el-form-item>

        <!--添加属性-->
          <!--<div class="text-right" style="margin:10px;margin-right: 100px;">-->
            <!--<el-button type="text" @click="addParam=true">添加属性</el-button>-->
          <!--</div>-->
          <el-form-item label=" " prop=""   v-for="(item,index) in dishesExtends">
            <el-input :placeholder="'请输入'+item.name" v-model="item.value" :maxlength="50" >
              <template slot="prepend">
                <el-button tabIndex="-1">{{item.name}}</el-button>
              </template>
              <template slot="append" ><i class="el-icon-delete" @click="delParam(index)"></i></template>
            </el-input>
          </el-form-item>
          <el-form-item prop="introduction" :rules="[,{max: 200, message: '长度最长200个字符', trigger: 'blur' }]">
            <el-input
              type="textarea"
              :rows="3"
              placeholder="请填写简介"
              v-model="modelForm.introduction" :maxlength="200">
            </el-input>
          </el-form-item>
          <el-form-item label=" " prop="state" :rules="[]">
            <el-radio class="radio" v-model="modelForm.state" label="NORMAL">在售</el-radio>
            <el-radio class="radio" v-model="modelForm.state" label="DISABLED">停售</el-radio>
          </el-form-item>
          <el-form-item label=" " prop="rank" :rules="[]">
            <el-checkbox v-model="modelForm.rank">参与销量排名</el-checkbox>
          </el-form-item>
        </el-form>
      </div>
      <br>
      <div class="text-left" style="margin-left:142px">
        <el-button :disabled="canSave" type="primary" size="medium" @click="submitValid()">
          <span v-if="canSave"><i class="el-icon-loading"></i>提交中</span>
          <span v-else>提交</span>
        </el-button>
        <!--<el-button type="primary" @click="submitValid()">提交</el-button>-->
        <el-button @click="goBack">返回</el-button>
      </div>
      <br>
      <br>
      <addParamModel :isShow="addParam" v-on:close="addParamClose" v-on:addSuccess="addParamSuccess"></addParamModel>
    </div>

  </div>
</template>
<script>
  import Vue from 'vue';
  import addParamModel from './addParamModel.vue'
  Vue.component('my-item-zh', {
    functional: true,
    render: function (h, ctx) {
      var item = ctx.props.item;
      return h('li', ctx.data, [
        h('div', { attrs: { class: 'name' } }, [item.name]),
      ]);
    },
    props: {
      item: { type: Object, required: true }
    }
  });
  //注意路径
  export default {
    data() {
      return {
        dishesExtends:[],
        addParam:[],
        canSave:false,
        showInfo: false,
        modelForm: {},
        checkAll: false,
        checkFeed: [],
        isIndeterminate: true,
        showDialog: false,
        activityId: "",
        isSave: true,
        activeName: "info",
        categoryList: [],
        makeCategoryList: [],
        dishesUnitList: [],
        copyUnits:[],
        commissionTypes: [],
        printerCategoryUnitList: [],
        moreSpecifications: false,
        morePractice: false,
        isFeed:false,
        dishesSpecificationList: [],
        dishesPracticeList: [],
        feedList: [],
        feedCategoryList: [],
        allDishesMakeList: [], //所有做法
        allFeedList: [],  //所有加料分类
        selectMake: "", //做法分类选中
        selectMakeName: "", //做法分类选中
        selectFeed:"",   //加料分类选中
        marks:[],  //提交做法数组
        feeds:[],   //提交加料数组
        specificationsTableData: [
          /*{
            specificationsId: '',
            money: '0.00',
            vipMoney: '0.00',
            isDefault: false,
            specName:""
          }*/
        ],
        tableData: [/*{
          practiceId: '',
          premiumRate: 'DONOTADD',
          money: '0.00',
          def:false
        }*/],
        priceupTypes: [],
        storeId: window.localStorage.getItem("dishKuId"),
        storeType: window.localStorage.getItem("dishKuType"),
        stockForm:{}, //库存信息
        storeModes:[], //存储方式
        stocktakeTypes:[], //盘点类型
        orderTypes:[], //订货类型
//        purchase: [{purchaseSpec: "", purchaseUnit: "", purchaseCount: 1, purchasePrice: 0, isDeleted: false}],
        purchase: [],
        purchaseModel: {purchaseSpec: "", purchaseUnit: "", purchaseCount: 0, purchasePrice: 0, isDeleted: true,hasDef:false},
        purIndex:"",
        stockShowInfo:true, //库存信息展开隐藏
        makeUpdate:false,
        codeList:[{code:""}],//商品条码
        selectUnitIndex:"",
        hasDefPurchaseId:"",
        dishesSpecificationListCopy:[],
        brands:[]
      }
    },
    components: {
      addParamModel
    },
    created() {
      window.this = this;
      this.canSave=false;
      if (this.$route.query.id && this.$route.query.id != '') {
        this.activityId = this.$route.query.id;
        this.isSave=false;
        this.$axios.get("dishes/dishess/" + this.activityId + "/update?storeId=" + this.storeId).then(data => {
          //存储方式
          this.storeModes = data.content.storeModes;
          //订货类型
          this.orderTypes = data.content.orderTypes;
          //盘点类型
          this.stocktakeTypes = data.content.stocktakeTypes;
          this.brands = data.content.brands;


          this.feedList = [];
          this.categoryList = data.content.categoryList;  //菜品分类
          this.dishesUnitList = data.content.unitList;   //单位list
          this.copyUnits = data.content.unitList;   //单位list
          this.commissionTypes = data.content.dishesCommissionTypes;
          this.dishesExtends=data.content.dishesExtends;
          this.allFeedList = data.content.feedList;

          this.printerCategoryUnitList = data.content.printerCategoryUnitList;
          if (data.content.specificationList.length > 0) {
            this.dishesSpecificationList = data.content.specificationList;
          }
          this.allDishesMakeList = data.content.dishesMakeList; //所有做法

          this.priceupTypes = data.content.priceupTypes;//加价比例
          data.content.dishes.category=data.content.dishes.category.id;

          this.modelForm = data.content.dishes;

          if(data.content.dishes.code){
            this.codeList=[];
            var codes = JSON.parse(data.content.dishes.code);
            if(codes && codes.length>0){
              for(var i=0;i<codes.length;i++){
                this.codeList.splice(i,0,{code:codes[i]});
              }
            }
//            this.codeList = ;
          }


          //库存信息
          this.stockForm = data.content.material;
          //多采购规格
          this.purchase.splice(0, 1);
          if(data.content.purchase && data.content.purchase.length>0){
            for (var i = 0; i < data.content.purchase.length; i++) {
              if(!data.content.purchase[i].hasDef){
                data.content.purchase[i].isDeleted = false;
                this.purchase.push(data.content.purchase[i]);
              }else{
                this.hasDefPurchaseId = data.content.purchase[i].id;
              }
            }
          }

          //商品规格
          if(data.content.specificationRelationList && data.content.specificationRelationList.length>0){   //多规格数据还原
            this.moreSpecifications=true;
            var duoGuiGe=data.content.specificationRelationList;
            this.specificationsTableData=[];
            if(duoGuiGe && duoGuiGe.length>0){
              //true 不用监听多规格
              for(var i=0;i<duoGuiGe.length;i++){
//              console.log(duoGuiGe[i].specId)
                if(duoGuiGe[i].specId==undefined || duoGuiGe[i].specId==''){
                  this.moreSpecifications=false;
                 /* this.specificationsTableData=[{
                    specificationsId: '',
                    money: '0.00',
                    vipMoney: '0.00',
                    isDefault: false,
                    specName:""
                  }];*/
                  break;
                }

                  this.specificationsTableData.push(
                    {
                      specificationsId:duoGuiGe[i].specId,
                      money:duoGuiGe[i].price,
                      vipMoney:duoGuiGe[i].vipPrice,
                      isDefault:duoGuiGe[i].def,
                      specName:duoGuiGe[i].specName
                    }
                  )

              }
            }

          }
          this.dishesSpecificationListCopy = this.specificationsTableData;


          /*--------------做法数据开始---------------*/

          this.makeUpdate = true;
          if(data.content.makeRelationList && data.content.makeRelationList.length>0){             //多做法数据还原  是多做法
            this.morePractice=true;
            this.tableData=[];


            var duoZuoFa=JSON.parse(JSON.stringify(data.content.makeRelationList));
            if(duoZuoFa.length>0){
              this.selectMake=duoZuoFa[0].makeCategoryId;
              this.selectMakeName=duoZuoFa[0].makeCategoryName;
            }

            var makeCatory=data.content.makeCategoryList;
            for(var j=0;j<makeCatory.length;j++){
              makeCatory[j].calcCount=0;
            }
            for(var i=0;i<duoZuoFa.length;i++){
              duoZuoFa[i].priceupType= duoZuoFa[i].priceupType.key
            };
            for(var i=0;i<duoZuoFa.length;i++){
//              console.log(duoZuoFa[i]);
                if(duoZuoFa[i].makeCategoryId==this.selectMake){
                  this.tableData.push({
                    practiceId:duoZuoFa[i].makeId,
                    premiumRate: duoZuoFa[i].priceupType,
                    money:duoZuoFa[i].val,
                    def:duoZuoFa[i].def,
                  })
                }
              for(var k=0;k<makeCatory.length;k++){
                if(duoZuoFa[i].makeCategoryId==makeCatory[k].id){
                  makeCatory[k].calcCount++;
                }
              }
            }
            this.makeCategoryList = makeCatory;  //做法分类list
            this.marks=duoZuoFa;

          }else{                  //不是多做法
            data.content.makeCategoryList.forEach(function (item, index, array) {
              array[index].calcCount = 0;
            });
            if(data.content.makeCategoryList.length>0){
              this.selectMake = data.content.makeCategoryList[0].id;
              this.selectMakeName = data.content.makeCategoryList[0].name;
            }
            this.makeCategoryList = data.content.makeCategoryList;  //做法分类list
            this.allDishesMakeList = data.content.dishesMakeList; //所有做法
          }

          if(this.allDishesMakeList && this.allDishesMakeList.length>0){
            for (var i = 0; i < this.allDishesMakeList.length; i++) {//多做法默认选中第一个分类下的做法
              if (this.selectMake == this.allDishesMakeList[i].typeId) {
                this.dishesPracticeList.push(this.allDishesMakeList[i]);
              }
            }
          }

          //-----------------------做法数据结束---------------------------


          /*----------------------------加料数据开始------------------------------*/
          var feedCategoryList=data.content.feedCategoryList;
          if(feedCategoryList && feedCategoryList.length>0){
            for(var i=0;i<feedCategoryList.length;i++){
              feedCategoryList[i].calcCount=0;
            }
          }


          if(data.content.feedRelationList && data.content.feedRelationList.length>0){
            this.isFeed=true;
            var feedList=data.content.feedRelationList;
            if(feedList.length>0){
              this.selectFeed=feedList[0].categoryId;
            }
            this.feeds=data.content.feedRelationList;
            this.checkFeed=[];
             for(var i=0;i<feedList.length;i++){
               this.checkFeed.push(feedList[i].feedId);
               for(var j=0;j<feedCategoryList.length;j++){
                 if(feedList[i].categoryId==feedCategoryList[j].id){
                   feedCategoryList[j].calcCount++;
                 }
               }
             }
            for (var i = 0; i < this.allFeedList.length; i++) {//加料默认选中第一个分类下的做法
              if (this.selectFeed == this.allFeedList[i].typeId) {
                this.feedList.push(this.allFeedList[i]);
              }
            }
            this.feedCategoryList = feedCategoryList;
          }else{
            if(data.content.feedCategoryList.length>0){
              this.selectFeed = data.content.feedCategoryList[0].id;
            }
            data.content.feedList.forEach(function (item, index, array) {
              array[index].isChecked = false;
            });
            data.content.feedCategoryList.forEach(function (item, index, array) {
              array[index].calcCount = 0;
            });
            this.allFeedList = data.content.feedList;
            this.feedCategoryList = data.content.feedCategoryList;
            for (var i = 0; i < this.allFeedList.length; i++) {//多做法默认选中第一个分类下的做法
              if (this.selectFeed == this.allFeedList[i].typeId) {
                this.feedList.push(this.allFeedList[i]);
              }
            }
          }


          if (this.feedCategoryList && this.feedCategoryList.length>0){
            for(var i=0;i<this.feedCategoryList.length;i++){
              if(this.selectFeed==this.feedCategoryList[i].id){
                this.checkAll = this.feedCategoryList[i].calcCount === this.feedList.length;
                this.isIndeterminate = this.feedCategoryList[i].calcCount > 0 && this.feedCategoryList[i].calcCount < this.feedList.length;
                break;
              }
            }
          }

//          console.log(this.checkAll);

          /*--------------------------加料数据结束----------------------------------*/
        });
      } else {
        this.isSave=true;
        this.$axios.get("dishes/dishess/create?storeId=" + this.storeId).then(data => {

          //存储方式
          this.storeModes = data.content.storeModes;
          //订货类型
          this.orderTypes = data.content.orderTypes;
          //盘点类型
          this.stocktakeTypes = data.content.stocktakeTypes;
          this.brands = data.content.brands;

          //库存信息
          this.dishesExtends=data.content.dishesExtends;
          this.stockForm = data.content.material;
          this.categoryList = data.content.categoryList;  //菜品分类
          this.dishesUnitList = data.content.unitList;   //单位list
          this.copyUnits = data.content.unitList;   //单位list
          this.commissionTypes = data.content.dishesCommissionTypes;
          if(data.content.feedList && data.content.feedList.length>0){
            data.content.feedList.forEach(function (item, index, array) {
              array[index].isChecked = false;
            });
          }
          this.allFeedList = data.content.feedList;
          data.content.feedCategoryList.forEach(function (item, index, array) {
            array[index].calcCount = 0;
          });
          if(data.content.feedCategoryList.length>0){
            this.selectFeed = data.content.feedCategoryList[0].id;
          }
          for (var i = 0; i < this.allFeedList.length; i++) {//多做法默认选中第一个分类下的做法
            if (this.selectFeed == this.allFeedList[i].typeId) {
              this.feedList.push(this.allFeedList[i]);
            }
          }
          this.feedCategoryList = data.content.feedCategoryList;

          this.printerCategoryUnitList = data.content.printerCategoryUnitList;
          data.content.dishes.commissionType = data.content.dishes.commissionType.key;
          if (data.content.specificationList.length > 0) {
            this.dishesSpecificationList = data.content.specificationList;
          }
          if(data.content.makeCategoryList.length>0){
            this.selectMake = data.content.makeCategoryList[0].id;
            this.selectMakeName = data.content.makeCategoryList[0].name;
          }

          data.content.makeCategoryList.forEach(function (item, index, array) {
            array[index].calcCount = 0;
          });
          this.makeCategoryList = data.content.makeCategoryList;  //做法分类list
          this.allDishesMakeList = data.content.dishesMakeList; //所有做法
          for (var i = 0; i < this.allDishesMakeList.length; i++) {//多做法默认选中第一个分类下的做法
            if (this.selectMake == this.allDishesMakeList[i].typeId) {
              this.dishesPracticeList.push(this.allDishesMakeList[i]);
            }
          }
          this.priceupTypes = data.content.priceupTypes;//加价比例
          this.modelForm = data.content.dishes;

          this.modelForm.commissionType=data.content.dishesCommissionTypes[0].key

          this.makeUpdate = false;
        });
      }
    },
    mounted() {
    },
    watch:{
      moreSpecifications:function(newValue,oldValue){
//          console.log(this.isSave);
          if(this.dishesSpecificationList && this.dishesSpecificationList.length>0 ){
            if(this.isSave){
              //新建
              if(newValue){
                this.specificationsTableData.push(
                  {
                    specificationsId:this.dishesSpecificationList[0].id,
                    money:0.0,
                    vipMoney:0.0,
                    isDefault:true,
                    specName:this.dishesSpecificationList[0].name
                  }
                )
              }else{
                this.specificationsTableData=[];
              }

            }else{
              //编辑
              this.specificationsTableData = [];
//              console.log(this.dishesSpecificationListCopy);
              if(this.dishesSpecificationListCopy && this.dishesSpecificationListCopy.length>0){
                //编辑有数据
                this.specificationsTableData = this.dishesSpecificationListCopy;
                return;
              }else {
                if(newValue){
                  this.specificationsTableData.push(
                    {
                      specificationsId:this.dishesSpecificationList[0].id,
                      money:0.0,
                      vipMoney:0.0,
                      isDefault:true,
                      specName:this.dishesSpecificationList[0].name
                    }
                  )
                }
              }
            }
          }

      },
      morePractice:function (newValue,oldValue) {

        if(!this.makeUpdate){
          if(newValue){

            if(this.dishesPracticeList && this.dishesPracticeList.length>0 ){
//              console.log(this.dishesPracticeList[0]);
              this.tableData.push(
                {
                  practiceId:this.dishesPracticeList[0].id,
                  premiumRate: this.dishesPracticeList[0].priceupType.key,
                  money:0.0,
                  def:true,
                }
              )
              this.marks.push(
                {
                  makeId:this.dishesPracticeList[0].id,
                  name:this.dishesPracticeList[0].name,
                  makeCategoryId:this.dishesPracticeList[0].typeId,
                  makeCategoryName:this.selectMakeName,
                  priceupType:this.dishesPracticeList[0].priceupType.key,
                  val:0.0,
                  def:true
                }
              )

              //this.makeCategoryList[i].calcCount
              if(this.makeCategoryList && this.makeCategoryList.length){
                for(var m=0;m<this.makeCategoryList.length;m++){
                  if(this.makeCategoryList[m].id == this.selectMake){
                    this.makeCategoryList[m].calcCount = this.tableData.length;
                  }
                }
              }


            }

          }else {

            this.tableData = [];
            this.marks = [];
            for(var m=0;m<this.makeCategoryList.length;m++){
              this.makeCategoryList[m].calcCount = 0;
            }
            if(this.makeCategoryList && this.makeCategoryList.length>0){
              this.selectMake = this.makeCategoryList[0].id;
              this.selectMakeName = this.makeCategoryList[0].name;
            }
          }
        }
      }
    },
    methods: {
      /*属性添加确定及取消事件*/
      addParamClose(){
        this.addParam=false;
      },
      addParamSuccess(data){

        console.log( this.dishesExtends);
        if(data && data.length>0){
          for(var i=0;i<data.length;i++){
            this.dishesExtends.push({name:data[i].name,value:data[i].value});
          }
        }


        console.log(data);
        this.addParam=false;
      },
      delParam(index){
        this.dishesExtends.splice(index,1);
      },
      changePrice(){
        this.modelForm.vipPrice = this.modelForm.price;
      },
      findUnit(){
        var unit=this.dishesUnitList.find(data=>{
          if(data.name==this.modelForm.unit){
            return true;
          }else{
            return false;
          }
        })
//        console.log(unit);
      },
      querySearch(queryString, cb) {

        var restaurants = this.dishesUnitList;
        var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
        // 调用 callback 返回建议列表的数据
//        console.log(results);
        if(results.length<=0){
          this.$message.error("该单位不存在")
        }
        for(let i of results){
          i.value = i.name;  //将想要展示的数据作为value
        }
        cb(results);
      },
      createFilter(queryString) {
        return (restaurant) => {
//          console.log(restaurant);
          return (restaurant.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0) && restaurant.state.key=='NORMAL';
        };
      },
      handleSelect(item){

        this.modelForm.unit=item.name
      },
      selectConsumeUnit(index){
        this.selectUnitIndex=index;
      },
      handleSelect2(item){
        this.purchase[this.selectUnitIndex].purchaseUnit=item.name
      },
      addCode(){
        this.codeList.push({code:""});
      },
      delCode(index){
        if(this.codeList.length>1){
          this.codeList.splice(index,1);
        }else{
          this.$message.info("最少保留一条");
        }
      },
      isNumber(item,key){
//              var r=/^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
        var r = /^\+?[1-9][0-9]*$/;

        if(!r.test(item[key])){
          this.stockForm.orderPriceBom = 0.0;
//          item[key]="0.00"
          this.$forceUpdate();
        }else{
          item[key]=item[key]
        }
      },

      /*添加采购规格*/
      addPurchase() {
        this.purchase.push(this.purchaseModel);
        this.purchaseModel = {
          purchaseSpec: "",
          purchaseUnit: null,
          purchaseCount: 0,
          purchasePrice: 0,
          isDeleted: true,
          hasDef:false
        };
      },

      /*删除*/
      delPurchase(index) {
        this.purchase.splice(index, 1);
        /*if (this.purchase.length > 1) {
          this.purchase.splice(index, 1);
        } else {
          this.$message.info("最少保留一条");
        }*/
      },
      getIndex(index){
        this.purIndex=index;
      },

      selectPurchaseUnit(val){
        if (val) { //val存在
          this.dishesUnitList =  this.copyUnits.filter((item) => {
            if(val==item.name){
              return true;
            }
          })
          if(!this.dishesUnitList || (this.dishesUnitList && this.dishesUnitList.length==0)){
            this.dishesUnitList.push({
              name:val
            });
          }
        } else { //val为空时，还原数组
          this.dishesUnitList.push({
            name:val
          });
        }
        this.$forceUpdate();
        this.purchase[this.purIndex].purchaseUnit=val;
      },

      isPositive(item, key) {
        let num = parseFloat(item[key]);
        if (!isNaN(num) && (isFinite(num)) && (num > 0)) {
          item[key] = num + "";
        } else {
          item[key] = "1";
        }
      },

      unitBlur(){
        this.dishesUnitList = this.copyUnits;
      },
      selectUnit(val){
        if (val) { //val存在
          this.dishesUnitList =  this.copyUnits.filter((item) => {
            if(val==item.name){
              return true;
            }
          })
          if(!this.dishesUnitList || (this.dishesUnitList && this.dishesUnitList.length==0)){
            this.dishesUnitList.push({
              name:val
            });
          }
        } else { //val为空时，还原数组
          this.dishesUnitList.push({
            name:val
          });
        }
        this.$forceUpdate();
        this.modelForm.unit=val;
      },
      printNum(){
        event.currentTarget.select();
      },
      getValue(value){
//        console.log(value);
      },
      handleCheckAllChange(val) {
        var ids = [];
        // if (val) {
          for (var i = 0; i < this.feedList.length; i++) {
            ids.push(this.feedList[i].id);
          }
        // }
        if(val){
          for (var i = 0; i < this.feedList.length; i++) {
            this.checkFeed.push(this.feedList[i].id);
          }
        }else{
          for (var i = 0; i < this.feedList.length; i++) {
            var index = this.checkFeed.indexOf(this.feedList[i].id);
            if (index > -1) {
              this.checkFeed.splice(index, 1);
            }
          }
        }
        //全选的时候val为true的时候，类别上边数量++ 并且全局push进加料llist
        if(val){
          this.publicPushFeedsAndCatrgoryChange(ids);
        }else{
          for(var i=0;i<ids.length;i++){
            for(var j=0;j<this.allFeedList.length;j++){
              if(ids[i]==this.allFeedList[j].id){
                for(var n=0;n<this.feedCategoryList.length;n++){
                  if(this.allFeedList[j].typeId==this.feedCategoryList[n].id){
                    if (this.feedCategoryList[n].calcCount == 0) {
                      return;
                    }
                      this.feedCategoryList[n].calcCount--;
                  }
                }
                for(var k=0;k<this.feeds.length;k++){
                  if(ids[i]==this.feeds[k].feedId){
                    this.feeds.splice(k,1);
                  }
                }
              }
            }
          }
        }
        this.isIndeterminate = false;
      },

      /*加料分类calcCount相加，并且push进全局变量*/
      publicPushFeedsAndCatrgoryChange(value){
        this.feeds=[];
        for (var j = 0; j < value.length; j++) {
          for (var i = 0; i < this.allFeedList.length; i++) {
            if(value[j]==this.allFeedList[i].id){
              for(var n=0;n<this.feedCategoryList.length;n++){
                if(this.allFeedList[i].typeId==this.feedCategoryList[n].id){
                  var count=0;
                  for(var k=0;k<this.feeds.length;k++){
                     if(this.allFeedList[i].id==this.feeds[k].feedId){
                        count++;
                     }
                  }
                  if(count>0){

                  }else{
                    this.feedCategoryList[n].calcCount++;
                    this.feeds.push({
                      categoryId:this.feedCategoryList[n].id,
                      categoryName:this.feedCategoryList[n].name,
                      feedId:this.allFeedList[i].id,
                      name:this.allFeedList[i].name,
                      price:this.allFeedList[i].price

                    })
                  }

                }

              }
            }
          }
        }
      },
      handleCheckedCitiesChange(value) {
        for(var n=0;n<this.feedCategoryList.length;n++){
          this.feedCategoryList[n].calcCount = 0;
        }
        this.feeds=[];
        this.publicPushFeedsAndCatrgoryChange(value);
        if(this.feedCategoryList && this.feedCategoryList.length>0){
          for(var i=0;i<this.feedCategoryList.length;i++){
              if(this.selectFeed==this.feedCategoryList[i].id){
                this.checkAll = this.feedCategoryList[i].calcCount === this.feedList.length;
                this.isIndeterminate = this.feedCategoryList[i].calcCount > 0 && this.feedCategoryList[i].calcCount < this.feedList.length;
                break;
              }
          }
        }
      },
      getCurrentMakeCategory(MakeCategoryId,typeId,name) {
        this.selectMake = MakeCategoryId;
        this.selectMakeName = name;
        //筛选当前做法分类下的做法，添加进dishesPracticeList
        this.dishesPracticeList = [];

        for (var i = 0; i < this.allDishesMakeList.length; i++) {
          if (MakeCategoryId == this.allDishesMakeList[i].typeId) {
            this.dishesPracticeList.push(this.allDishesMakeList[i]);
          }
        }
        this.tableData = [];
        var count = 0;
        for(var j=0;j<this.marks.length;j++){
          if(MakeCategoryId==this.marks[j].makeCategoryId){
           count++;
          }
        }
        if(count>0){
          this.tableData = [];
        }else {
          this.tableData = [{
            practiceId: '',
            premiumRate: 'DONOTADD',
            money: '0.00',
            def:false
          }];
        }

        for(var j=0;j<this.marks.length;j++){
          if(MakeCategoryId==this.marks[j].makeCategoryId){
            this.tableData.push({
              practiceId: this.marks[j].makeId,
              premiumRate: this.marks[j].priceupType,
              money: this.marks[j].val,
              typeId:this.marks[j].makeCategoryId,
              typeName:this.marks[j].makeCategoryName,
              name:this.marks[j].name,
              def:this.marks[j].def
            });
          }
        }


      },
      /**
       * 切换加料类别
       * @param feedCategoryId
       * @param calcCount
       */
      getCurrentFeedCategory(feedCategoryId,calcCount) {
        //筛选当前做法分类下的做法，添加进dishesPracticeList
        this.feedList = [];
        this.selectFeed=feedCategoryId;
        for (var i = 0; i < this.allFeedList.length; i++) {
          if (feedCategoryId == this.allFeedList[i].typeId) {
            this.feedList.push(this.allFeedList[i]);
          }
        }

        //全选 显示
        this.checkAll = calcCount === this.feedList.length;
        this.isIndeterminate = calcCount > 0 && calcCount < this.feedList.length;

      },
      setPy() {
        if (this.modelForm.name) {
          this.$forceUpdate();
          this.modelForm.pinyin = window.getPy(this.modelForm.name);
          this.modelForm.spell = window.getIndexPy(this.modelForm.name);
        }
      },
      addColumn(index) {
        this.tableData.splice(index + 1, 0, {
          practiceId: '',
          premiumRate: 'DONOTADD',
          money: '0.00',
          def:false
        })
      },
      addSpecifColumn(index) {
        this.specificationsTableData.splice(index + 1, 0, {
          specificationsId: '',
          money: '0.00',
          vipMoney: '0.00',
          isDefault: false,
          specName:""
        })
      },
      minusColumn(index) {
        var typeId = "";
        for (let i = 0; i < this.dishesPracticeList.length; i++) {
          if (this.dishesPracticeList[i].id == this.tableData[index].practiceId) {
            typeId = this.dishesPracticeList[i].typeId;

          }
        }
        if (this.tableData.length > 1) {
          for(var i=0;i<this.marks.length;i++){
            if(this.tableData[index].practiceId==this.marks[i].makeId){
              this.marks.splice(i,1);
            }
          }
          this.tableData.splice(index, 1);


          if (typeId != '') {
            for (let i = 0; i < this.makeCategoryList.length; i++) {
              if (typeId == this.makeCategoryList[i].id) {
                if (this.makeCategoryList[i].calcCount == 0) {
                  return;
                }
                this.makeCategoryList[i].calcCount--;
              }
            }
          }

        } else {
          this.$message.info("最少保留一条");
          if (typeId != '') {
            for (let i = 0; i < this.makeCategoryList.length; i++) {
              if (typeId == this.makeCategoryList[i].id) {
                this.makeCategoryList[i].calcCount=0;
              }
            }
          }
          for(var i=0;i<this.marks.length;i++){
            if(this.tableData[index].practiceId==this.marks[i].makeId){
              this.marks.splice(i,1);
            }
          }
          this.tableData=[
            {  practiceId: '',
              premiumRate: 'DONOTADD',
              money: '0.00',
              def:false}
          ]



        }
      },
      minusSpecifColumn(index) {
        if (this.specificationsTableData.length > 1) {
          this.specificationsTableData.splice(index, 1);
        } else {
          this.$message.info("最少保留一条");
        }
      },
      goBack() {
        this.router.go(-1);
      },
      handleAvatarSuccess(res, file) {
        this.$set(this.modelForm,"img",res.content)
        this.modelForm.img =res.content ;
      },
      beforeAvatarUpload(file) {
        const isJPG = file.type === 'image/jpeg';
        const isLt2M = file.size / 1024 / 1024 < 2;
        if (!isLt2M) {
          this.$message.error('上传图片大小不能超过 2MB!');
        }
        return isLt2M;
      },
      submitValid() {
        if (this.moreSpecifications) {
          var defaultCount = 0;
          for (var i = 0; i < this.specificationsTableData.length; i++) {
            if (this.specificationsTableData[i].isDefault) {
              defaultCount++;
            }
          }
          if (defaultCount <= 0) {
            this.$message.error("菜品规格必须有默认值");
            return
          }
          if (!this.specificationsTableData[0].specificationsId) {
            this.$message.error("菜品规格第一行不能为空");
            return
          }
        }

        if (this.morePractice) {
          var count = 0;
          for (var i = 0; i < this.tableData.length; i++) {
            if (this.tableData[i].def) {
              count++;
            }
          }
          if (count <= 0) {
            this.$message.error("菜品做法必须有默认值");
            return
          }
          if (!this.tableData[0].practiceId) {
            this.$message.error("菜品做法第一行不能为空");
            return
          }
        }
        if(this.isFeed){
          if(!this.checkFeed || (this.checkFeed && this.checkFeed.length<=0)){
            this.$message.error("加料不能为空");
            return;
          }
        }


        this.$refs["modelFormInfo"].validate((valid) => {
          if (valid) {
            this.$refs["modelFormImg"].validate((valid) => {
              if (valid) {
                this.submitForm();
              } else {
                this.$message.error("请检查输入项");
                return false;
              }
            });
          } else {
            this.$message.error("请检查输入项");
            return false;
          }
        });
      },
      submitForm() {
        var data = {};
        this.modelForm.storeId=this.storeId;
        data.dishes=this.modelForm;
        var specs=[];

        if(this.moreSpecifications){
          for(var j=0;j<this.specificationsTableData.length;j++){
            specs.push({
              specId:this.specificationsTableData[j].specificationsId,
              price:this.specificationsTableData[j].money,
              vipPrice:this.specificationsTableData[j].vipMoney,
              def:this.specificationsTableData[j].isDefault,
              specName:this.specificationsTableData[j].specName});
          }
          data.specs=specs;
        }if(this.morePractice){
          data.marks=this.marks;
        }
        if(this.isFeed){
          var feeds = [];
          //feeds:[{categoryId:加料类别,categoryName:类别名称,feedId:加料id,name:名称,price:价格}] -- 多加料
          if(this.checkFeed && this.checkFeed.length>0){
            this.checkFeed.forEach(x=>{
              if(this.allFeedList && this.allFeedList.length>0){
                this.allFeedList.forEach(t=>{
                   if(x==t.id){
                      feeds.push({
                        categoryId:t.typeId,
                        categoryName:t.typeName,
                        feedId:t.id,
                        name:t.name,
                        price:t.price
                      });
                   }
                })
              }
            })
          }
          data.feeds = feeds;

        }
        var ary = this.codeList;
        var nary=ary.sort();
        for(var i=0;i<ary.length;i++){
          if(i>=ary.length-1){
            break;
          }
          if (nary[i].name!='' && nary[i+1].name!='' && nary[i].name==nary[i+1].name){
            this.$message.error("条码不能重复");
            return;
          }
        }
        var codes = [];
//        if(this.storeType=='SX' || this.storeType=='LS'){
          if(this.codeList && this.codeList.length>0){
            for(var i=0;i<this.codeList.length;i++){
              if(this.codeList[i].code!=''){
                codes.push(this.codeList[i].code);
              }
            }
          }
//        }
        if(codes && codes.length>0){
          data.dishes.codes = JSON.stringify(codes);
        }else {
          data.dishes.codes ="";
        }
        var ary = this.dishesExtends;
        var nary=ary.sort();
        for(var i=0;i<ary.length;i++){
          if(i>=ary.length-1){
            break;
          }
          if (nary[i].name!='' && nary[i+1].name!='' && nary[i].name==nary[i+1].name){
            this.$message.error("属性名称不能重复");
            return;
          }
        }
        if(this.dishesExtends && this.dishesExtends.length>0){
          data.dishes.extend = JSON.stringify(this.dishesExtends);
        }else {
          data.dishes.extend ="";
        }

        data.stockForm = this.stockForm;
        if(this.purchase && this.purchase.length>0){
          for (let i = 0; i < this.purchase.length; i++) {
//            console.log(this.$refs[ref])
            let ref = 'pur' + i;
            this.$refs[ref][0].validate((valid) => {
              if (valid) {
                data.purchase = this.purchase;
                data.purchase.push({
                  id:this.hasDefPurchaseId,
                  purchaseSpec: this.modelForm.unit,
                  purchaseUnit: this.modelForm.unit,
                  purchaseCount: 1,
                  purchasePrice: this.modelForm.futureCost,
                  isDeleted: true,
                  hasDef:true
                });
                this.submitFormSave(data);
              }else{
                this.$message.error("请检查采购规格");
                return false;
              }
            })
          };
        }else {
          data.purchase = [];
          data.purchase.push({
            id:this.hasDefPurchaseId,
            purchaseSpec: this.modelForm.unit,
            purchaseUnit: this.modelForm.unit,
            purchaseCount: 1,
            purchasePrice: this.modelForm.futureCost,
            isDeleted: true,
            hasDef:true
          });
          this.submitFormSave(data);
        }
      },
      submitFormSave(data){
        if(this.canSave){
          return;
        }
        this.canSave = true;
        if (!this.isSave) {
          this.modelForm._method = "PUT";
          this.$axios.put("dishes/dishess/" + this.activityId + "/update", data,"json").then(data=> {
            this.canSave=false;
            if (data.status == 200) {
              this.$message({
                message: data.message,
                type: 'success'
              });
              this.canSave = false;
//              this.clearData();
              this.activeName = "success";
              this.showInfo = false;
              this.router.push('/dishesMessage');
              $('.wrapper-content').animate({scrollTop: 0}, 'slow');
            } else {
              this.$message.error(data.message);
            }
          });
        } else {
          this.$axios.post("dishes/dishess/create", data,"json").then(data=> {
            this.canSave=false;
            if (data.status == 200) {
              this.$message({
                message: data.message,
                type: 'success'
              });
              this.canSave = false;
              this.clearData();
              this.showInfo = false;
              $('.wrapper-content').animate({scrollTop: 0}, 'slow');
              this.activeName = "success";
            } else {
              this.$message.error(data.message);
            }
          })
        }
      },
      resetForm(formName) {
        this.clearData();
        this.activeName = "info";
        this.$emit('close');
        this.$refs[formName].resetFields();
        this.showDialog = false;
      },
      clearData() {
        console.log("dddddddddddddddddd:",this.modelForm);
        this.isSave = true;
        this.moreSpecifications=false;
        this.morePractice=false;
        this.feedList=[];
        this.dishesPracticeList=[];
        var brandId = this.modelForm.brandId;
        var unit = this.modelForm.unit;
        var category = this.modelForm.category;



        this.modelForm = {};
        this.stockForm = {};
        this.purchase = [];
        this.codeList=[{code:""}];



//        this.addPurchase();
        this.$axios.get("dishes/dishess/create?storeId="+this.storeId).then(data=> {
          this.categoryList = data.content.categoryList;  //菜品分类
          this.dishesUnitList = data.content.unitList;   //单位list
          this.commissionTypes = data.content.dishesCommissionTypes;
          //库存信息
          this.stockForm = data.content.material;
          data.content.feedList.forEach(function (item, index, array) {
            array[index].isChecked = false;
          });

          this.allFeedList = data.content.feedList;
          data.content.feedCategoryList.forEach(function (item, index, array) {
            array[index].calcCount = 0;
          });
          if(data.content.feedCategoryList && data.content.feedCategoryList.length>0){
            this.selectFeed = data.content.feedCategoryList[0].id;
          }

          if(this.allFeedList && this.allFeedList.length>0){
            for (var i = 0; i < this.allFeedList.length; i++) {//多做法默认选中第一个分类下的做法
              if (this.selectFeed == this.allFeedList[i].typeId) {
                this.feedList.push(this.allFeedList[i]);
              }
            }
          }

          this.feedCategoryList = data.content.feedCategoryList;
          this.printerCategoryUnitList = data.content.printerCategoryUnitList;
          data.content.dishes.commissionType = data.content.dishes.commissionType.key;
          if (data.content.specificationList.length > 0) {
            this.dishesSpecificationList = data.content.specificationList;
          }
          if(data.content.makeCategoryList && data.content.makeCategoryList.length>0){
            this.selectMake = data.content.makeCategoryList[0].id;
            this.selectMakeName = data.content.makeCategoryList[0].name;
          }
          data.content.makeCategoryList.forEach(function (item, index, array) {
            array[index].calcCount = 0;
          });
          this.makeCategoryList = data.content.makeCategoryList;  //做法分类list
          this.allDishesMakeList = data.content.dishesMakeList; //所有做法
          if(this.allDishesMakeList && this.allDishesMakeList.length>0){
            for (var i = 0; i < this.allDishesMakeList.length; i++) {//多做法默认选中第一个分类下的做法
              if (this.selectMake == this.allDishesMakeList[i].typeId) {
                this.dishesPracticeList.push(this.allDishesMakeList[i]);
              }
            }
          }

          this.priceupTypes = data.content.priceupTypes;//加价比例
          this.modelForm = data.content.dishes;
          if(data.content.dishesCommissionTypes && data.content.dishesCommissionTypes.length>0){
            this.modelForm.commissionType=data.content.dishesCommissionTypes[0].key
          }

          this.modelForm.brandId=brandId;
          this.modelForm.unit = unit;
          this.modelForm.category = category;

          console.log("cccccccccccccccc:",this.modelForm);
        });
        this.specificationsTableData = [
          {
            specificationsId: '',
            money: '0.00',
            vipMoney: '0.00',
            isDefault: false,
          }
        ];
        this.tableData = [{
          practiceId: '',
          premiumRate: 'DONOTADD',
          money: '0.00',
          def:false
        }];
        this.feeds=[];
        this.marks=[];
        this.isFeed=false;
        this.checkFeed = [];
        this.isIndeterminate=false;
        this.checkAll = false;





      },
      handleClose(done) {
        this.clearData();
        this.activeName = "info";
        this.$emit('close');
        done();
      },
      result() {
        this.activeName = "info";
      },
      premiumRateChange(item) {
        // if(item.premiumRate!='DONOTADD'){
        //     item.money=1;
        // }
      },
      isNum(item, key) {
        if (item.type == 'PROPORTION') {
          var r = /^\+?[1-9][0-9]*$/;
          if (!r.test(item[key])) {
            item[key] = "0.00"
          } else {
            item[key] = item[key]
          }
        } else {
          this.isDouble(item, key);
        }
      },
      isDouble(item, key) {
        var isNum = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
        if (!isNum.test(item[key])) {
          item[key] = "0.00"
        } else {
          item[key] = item[key]
        }
      },
      moneyJiaoyan(item, key) {
        var isNum = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
        if (!isNum.test(item[key])) {
          item[key] = "0.00"
        } else {
          item[key] = item[key]
        }
        item["vipMoney"] = item[key];
        if (item["isDefault"]) {
          this.modelForm.price = item[key];
          this.modelForm.vipPrice = item["vipMoney"];
        }
      },
      vipMoneyJiaoyan(item, key) {
        var isNum = /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
//        console.log(item[key] + "---" + item["money"]);
        if (!isNum.test(item[key])) {
          item[key] = "0.00"
        } else if (item[key] * 1 > item["money"] * 1) {
          item[key] = item["money"]
        }
        if (item["isDefault"]) {
          this.modelForm.price = item["money"];
          this.modelForm.vipPrice = item["vipMoney"];
        }
      },
      defaultChange(index) {
        for (var i = 0; i < this.specificationsTableData.length; i++) {
          this.specificationsTableData[i].isDefault = false;
        }
        this.specificationsTableData[index].isDefault = true;
        var item = this.specificationsTableData[index];
        this.specificationsTableData.splice(index, 1);
        this.specificationsTableData.splice(index, 0, item);
        this.modelForm.price = this.specificationsTableData[index].money;
        this.modelForm.vipPrice = this.specificationsTableData[index].vipMoney;
      },
      defaultMakeChange(index){
        for (var i = 0; i < this.tableData.length; i++) {
          this.tableData[i].def = false;
        }
        this.tableData[index].def = true;
        for(var k=0;k<this.marks.length;k++){
          if(this.tableData[index].practiceId==this.marks[k].makeId){
            this.marks[k].def=true;
          }else{
            this.marks[k].def=false;
          }
        }
        var item = this.tableData[index];
        this.tableData.splice(index, 1);
        this.tableData.splice(index, 0, item);
      },
      changeGuige(index) {
        for (var i = 0; i < this.specificationsTableData.length; i++) {
          if (i != index && this.specificationsTableData[i].specificationsId == this.specificationsTableData[index].specificationsId) {
            this.$message.error("不能选择重复规格");
            this.specificationsTableData[index].specificationsId = ""
            this.specificationsTableData[index].specName = ""
          }
        }
        for(var j=0;j<this.dishesSpecificationList.length;j++){
          if(this.specificationsTableData[index].specificationsId ==this.dishesSpecificationList[j].id){
            this.specificationsTableData[index].specName=this.dishesSpecificationList[j].name
          }
        }
      },
      changeZuoFa(index) {

        this.$forceUpdate();
        for (var i = 0; i < this.tableData.length; i++) {
          if (i != index && this.tableData[i].practiceId == this.tableData[index].practiceId) {
            this.$message.error("不能选择重复做法");
//            this.tableData.splice(index,1);
//            this.addColumn(index);
            this.tableData = [];
            for(var j=0;j<this.marks.length;j++){
              if(this.selectMake==this.marks[j].makeCategoryId){
                this.tableData.push({
                  practiceId: this.marks[j].makeId,
                  premiumRate: this.marks[j].priceupType,
                  money: this.marks[j].val,
                  typeId:this.marks[j].makeCategoryId,
                  typeName:this.marks[j].makeCategoryName,
                  name:this.marks[j].name,
                  def:this.marks[j].def
                });
              }
            }

//            this.tableData[index].practiceId = "";
//            this.tableData[index].money = "0";


            return;
          }
        }
        var typeId = "";
        for (let i = 0; i < this.dishesPracticeList.length; i++) {
          if (this.dishesPracticeList[i].id == this.tableData[index].practiceId) {
            typeId = this.dishesPracticeList[i].typeId;
            if (this.dishesPracticeList[i]) {
              this.tableData[index].premiumRate = this.dishesPracticeList[i].priceupType.key;
            }
            this.tableData[index].money = this.dishesPracticeList[i].priceupValue;
            this.tableData[index].name=this.dishesPracticeList[i].name;
            this.tableData[index].typeId=this.dishesPracticeList[i].typeId;
            this.tableData[index].def=false;
            for (let i = 0; i < this.makeCategoryList.length; i++) {
              if (typeId == this.makeCategoryList[i].id) {
                this.makeCategoryList[i].calcCount = this.tableData.length;
//                console.log("ddddddddvvvvvvvvvvv");
//                console.log(this.tableData.length);
                this.tableData[index].typeName= this.makeCategoryList[i].name;
              }
            }
          }
        }
        this.marks.push(
          {
            makeId:this.tableData[index].practiceId,
            name:this.tableData[index].name,
            makeCategoryId:this.tableData[index].typeId,
            makeCategoryName:this.tableData[index].typeName,
            priceupType:this.tableData[index].premiumRate,
            val:this.tableData[index].money,
            def:this.tableData[index].def
          }
        );
      }
    },

  }
</script>
<style scoped>
  .el-form-item {
    margin-bottom: 10px !important;
  }

  .el-table tr {
    border-bottom: 1px solid #dfe6ec !important;
  }

  .text-left5 {
    display: none;
  }

  .title-info {
    background-color: #F8F8F8;
    border: 1px solid #e4e4e4;
    /*color: #23c6c8;*/
    font-weight: bold;
    padding: 10px;
    margin-bottom: 20px;
    /*width: 800px;*/
  }

  .myForm .el-form-item {
    margin-bottom: 20px !important;
    margin-left: -70px !important;
  }
  .stockForm .el-form-item {
    margin-bottom: 20px !important;
    margin-left: -70px !important;
  }
  .stockForm .cggg-con .el-form-item {
    margin-left: 0px !important;
  }

  .deco {
    color: #409EFF !important;
    text-decoration: underline !important;
  }

  /*动态编辑[采购规格]*/
  .cggg-con {
    width: 640px;
    background-color: #F9F9F9;
    border: 1px solid #cccccc;
    border-top: 3px solid #1ab394;
    margin: 0 10px 10px 29px;
    padding: 10px 15px 15px 15px;

  }
</style>
